﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace The_LarX
{
    public class DialogManager : Component
    {
        public List<Dialog> Dialogs = new List<Dialog>();

        public DialogManager(GameScreen Screen)
            : base(Screen)
        {

        }

        private int currentDialog;

        public bool Finished;

        private bool Showed;
        private Vector2 rectPosition = new Vector2(30, 720);
        // 30, 420

        public override void Update()
        {
            base.Update();

            if (Showed)
            {

                if (Dialogs.Count > currentDialog)
                {
                    Finished = false;
                    Dialogs[currentDialog].Update();
                    if (Dialogs[currentDialog].Finished)
                    {
                        currentDialog++;
                    }
                }
                else
                {
                    Finished = true;
                }
            }
            else
            {
                if (rectPosition.Y > 420)
                {
                    rectPosition.Y -= 10 * Engine.SpeedFactor;
                }
                else
                {
                    Showed = true;
                }
            }
        }

        public Color RectangleColor = Color.DarkGray;

        public override void Draw()
        {
            Engine.RenderManager.DrawRectangle(RectangleColor,
                new Rectangle((int)rectPosition.X, (int)rectPosition.Y, 1220, 300), null);
            if (Showed)
            {
                if (Dialogs.Count > currentDialog)
                {
                    Dialogs[currentDialog].Draw();
                }
            }

            base.Draw();
        }
    }
}
